﻿@using Jugg.Mapping.SysRole
@model IEnumerable<SysRoleMapping>
@{
    ViewBag.Title = "角色列表";
}
<div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li>
            <i class="ace-icon fa fa-home home-icon"></i>
            <a href="@Url.RouteUrl("homeIndex")">首页</a>
        </li>
        <li class="active">@ViewBag.Title</li>
    </ul>
</div>
<div class="page-content">
    <div class="page-header">
        <h1>
            @ViewBag.Title
        </h1>
    </div>
    <div class="row">
        <div class="col-sm-12">
            @PermissionRouteLinkIcon("添加角色", "editRole", null, new { @class = "btn btn-sm btn-pink btnEdit" }, new { @class = "glyphicon glyphicon-plus" })
        </div>
    </div>
    <div class="space-2"></div>
    @if (Model != null)
    {
        <div class="row">
            <div class="col-sm-12">
                <table id="user_datatable" class="table table-striped table-bordered table-hover dataTable no-footer">
                    <thead>
                        <tr>
                            <th width="300px">名称</th>
                            <th width="200px">录入人员</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>@item.Name</td>
                                <td>@item.SysUserName</td>
                                <td>
                                    @PermissionRouteLinkIcon("修改", "editRole", new RouteValueDictionary(new { id = item.Id }), new { @class = "btn btn-xs btn-info btnEdit", title = "修改" }, new { @class = "glyphicon glyphicon-pencil" })
                                    @PermissionRouteLinkIcon("删除", "deleteRole", new RouteValueDictionary(new { id = item.Id }), new { @class = "btn btn-xs btn-danger btnDelete", title = "删除" }, new { @class = "glyphicon glyphicon-trash" })
                                    @PermissionRouteLinkIcon("权限", "rolePermission", new RouteValueDictionary(new { id = item.Id }), new { @class = "btn btn-xs btn-purple", title = "设置权限" }, new { @class = "fa fa-bolt" })

                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">编辑角色</h4>
                    </div>
                    <div class="modal-body">
                        <i class="ace-icon fa fa-spinner fa-spin orange bigger-125"></i> 加载中...
                    </div>
                </div>
            </div>
        </div>

        <script>
            $(function () {
                $('.btnEdit').click(function (e) {
                    e.preventDefault();
                    var modal = $('#myModal').modal();
                    $.get(this.href, function (html) {
                        modal.find('.modal-body').html(html);
                    });
                });
                $(".btnDelete").click(function (e) {
                    e.preventDefault();
                    var url = $(this).attr('href');
                    $.modal.confirm('删除后将不可恢复，您确定要删除此角色？', function () {
                        $.get(url, function (data) {
                            $.modal.alert(data);
                        });
                    });
                });
            });
        </script>
    }
    </div>